#include "mainwindow.h"
#include "ui_mainwindow.h"

#include"MVCgamemode.h"
#include<QPainter>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //  设置窗口大小
    setFixedSize(MARGIN*2+BLOCK_SIZE*BOARD_GRAD_SIZE,
                 MARGIN*2+BLOCK_SIZE*BOARD_GRAD_SIZE);//窗口大小=边界*2+格子个数*格子大小

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);

    //绘制棋盘
    painter.setRenderHint(QPainter::Antialiasing,true);//抗锯齿？？？？

    for (int i=0;i<=BOARD_GRAD_SIZE;i++)
    {
        //从左到右，（i+1）条竖线
        painter.drawLine(MARGIN+BLOCK_SIZE*i,MARGIN,
                         MARGIN+BLOCK_SIZE*i,size().height()-MARGIN);

        //从上到下，（i+1）条横线
        painter.drawLine(MARGIN,MARGIN+BLOCK_SIZE*i,
                         size().width()-MARGIN,MARGIN+BLOCK_SIZE*i);
    }
}
